package com.aier.entrance.icsocket;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.Arrays;

import com.aier.common.common.Constant;

public class ReplayMessage implements Serializable{
       /**
     * 
     */
    private static final long serialVersionUID = 1L;
    private String command;
    public ReplayMessage(){
    }
    public ReplayMessage(String command) {
        super();
        this.command = command;
    }
   
    public String getCommand() {
        return command;
    }



        
    public void setCommand(String command) {
        this.command = command;
    }
   
   
    //返回消息总长度
    public int getLength(){
        return Constant.num_100;
    }
      
 
    public byte[] toBytes(){
        ArrayList<String> list = new ArrayList<String>();
        String str = "";
        String[] strs = null;
        if (this.command.indexOf(" ") != -1) {
            strs = this.command.split(" ");
            list.addAll(Arrays.asList(strs));
        } else {
            for (int i = 0; i < this.command.length() / 2; i++) {
                str = this.command.substring(i * 2, i * 2 + 2);
                list.add(str);
            }
        }
        //logger.debug("\r\t hexStrtoByte:" + list.toString());
        byte[] b = new byte[list.size()];
        try {
            for (int i = 0; i < b.length; i++) {
                b[i] = Integer.valueOf(list.get(i).toString(), Constant.num_16).byteValue();
            }
        } catch (NumberFormatException e) {
            return null;
        }
        return b;
     
    }
   
 
}
